/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gov.police.diary.util;

import javax.portlet.PortletRequest;

/**
 *
 * @author nmduc
 */
public class RequestUtil {

    private static String getParameterValue(PortletRequest request, String name) {
        return request.getParameter(name);
    }

    private static void setParameterValue(PortletRequest request, String name, String value) {
    }

    public static String getParameterStringVaue(PortletRequest request, String name, String defaultValue) {
        String value = getParameterValue(request, name);
        if (value == null) {
            value = defaultValue;
        }
        return value;
    }

    public static long getParameterLongVaue(PortletRequest request, String name, long defaultValue) {
        String value = getParameterValue(request, name);
        if (value == null) {
            return defaultValue;
        } else {
            return Long.parseLong(value);
        }
    }

    public static int getParameterIntVaue(PortletRequest request, String name, int defaultValue) {
        String value = getParameterValue(request, name);
        if (value == null) {
            return defaultValue;
        } else {
            return Integer.parseInt(value);
        }
    }
}
